<?php
/**
 * Created by PhpStorm.
 * User: 董坤鸿
 * Date: 2017/1/5
 * Time: 下午3:42
 */

namespace EWeiLink\JuPai\Http\Controllers;

use EWeiLink\JuPai\Services\PlannerRepo;
use EWeiLink\JuPai\JpControllerTrait;
use EWeiLink\JuPai\JuPai;
use Illuminate\Http\Request;

class PlannerController
{

    use JpControllerTrait;

    protected $repoService;

    public function __construct(PlannerRepo $repo)
    {
        $this->repoService = $repo;
    }

    /**
     * 理财师列表
     * @return mixed
     */
    public function index()
    {
        $user = request()->user();
        if (!$user->isInitUser()) {
            return $this->_error('权限不足');
        }
        $filter = JuPai::callBridgeHelper('get_filter', []);
        $page = request('page', 0);
        return $this->repoService->getList($filter, $page);
    }

    public function create()
    {
        abort(404);
    }

    public function store()
    {
        abort(404);
    }

    /**
     * 查看理财师
     * @param $id
     * @return \EWeiLink\JuPai\Planner
     */
    public function show($id)
    {
        return $this->repoService->find($id);
    }

    public function edit($id)
    {
        abort(403);
    }

    public function update(Request $request, $id)
    {
        abort(403);
    }

    public function destroy($id)
    {
        abort(403);
    }

    /**
     * 获取指定理财师的联系人列表
     * @param $id
     * @return mixed
     */
    public function contacts($id)
    {
        $user = request()->user();
        if (!$user->isInitUser()) {
            return $this->_error('权限不足');
        }
        return $this->repoService->getContactsList($id);
    }

}